import { Component, HostListener, OnDestroy, OnInit } from "@angular/core";
import { CommService } from "../comm-service";
import { sjgzxinModuledatas } from "../pubcomponent/pageTitle.datas";
import { MyhttpService } from "../myhttp.service";
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
import { MyValidator } from "../myvalidator-util";

declare var $: any;

@Component({
  template: `
  <div class="all_bg paddingTop">
    <div class="">
      <div class="marginBottom">
        <ng-container *ngIf="actionobj1.length">
          <portlet-action class="actions" [o]="actionobj1" (outhander)="actionHander($event)"></portlet-action>
        </ng-container>
      </div>
      <div class="portlet-body">
        <div class="row">
          <form class="form-horizontal" role="form">
            <div class="col-lg-2">
              <div class="form-group">
                <label class="control-label col-lg-4">姓名：</label>
                <div class="col-lg-8">
                  <input type="text" class="form-control" placeholder="姓名" name="xm" [(ngModel)]="s_obj.xm"/>
                </div>
              </div>
            </div>
            <div class="col-lg-3">
              <div class="form-group">
                <label class="control-label col-lg-3">身份证号：</label>
                <div class="col-lg-8">
                  <input type="text" class="form-control" placeholder="身份证号" name="sfzjhm"
                         [(ngModel)]="s_obj.sfzjhm"/>
                </div>
              </div>
            </div>
            <div class="col-lg-3">
              <div class="form-group">
                <label class="control-label col-lg-3">人员类型：</label>
                <div class="col-lg-8">
                  <select class="form-control" id="rylxSelect" name="rylx" [(ngModel)]="s_obj.rylxm"
                          (change)="inittable_ry()"></select>
                </div>
              </div>
            </div>
            <div class="col-lg-3">
              <div class="form-group">
                <label class="control-label col-lg-5">是否关联运送任务：</label>
                <div class="col-lg-7">
                  <select class="form-control" id="sfglrwSelect" name="sfglrw" [(ngModel)]="s_obj.sfglrw"
                          (change)="inittable_ry()"></select>
                </div>
              </div>
            </div>
            <div class="ccol-lg-1">
              <button type="button" class="btn blue" (click)="inittable_ry()">
                <i class="fa fa-search"></i> 搜索
              </button>
            </div>
          </form>
        </div>
        <div class="row">
          <div class="col-lg-12" *ngIf="table_ry">
            <my-table [o]="table_ry"></my-table>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fad" id="xq_ryModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">详情</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="col-lg-12" *ngIf="xqobj_ry">
                <xq-form [o]="xqobj_ry"></xq-form>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">确 定</button>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fad" id="add_ryModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel">
      <div class="modal-dialog smmodalwidth" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
              aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="myModalLabel">{{modaltitle}}</h4>
          </div>
          <div class="modal-body">
            <div class="row">
              <div class="form-horizontal" role="form" [formGroup]="formgroup_ry">
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      姓名：</label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="xmCtr"/>
                      <div
                        *ngIf="formgroup_ry.get('xmCtr').invalid&&formgroup_ry.get('xmCtr').dirty">
                          <span *ngIf="formgroup_ry.hasError('myrequire','xmCtr')">
                                <tool-tip [o]="formgroup_ry.getError('myrequire','xmCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="control-label col-lg-3">
                      <require-label></require-label>
                      性别：</label>
                    <div class="col-lg-8">
                      <div class="mt-radio-inline">
                        <label class="mt-radio">
                          <input type="radio" name="sex" checked/> 男
                          <span></span>
                        </label>
                        <label class="mt-radio">
                          <input type="radio" name="sex"/> 女
                          <span></span>
                        </label>
                      </div>
                      <div *ngIf="noReactiveFormField.sexwarnflag">
                        <tool-tip [o]="noReactiveFormField.sexwarntext"></tool-tip>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      联系电话：
                    </label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="lxdhCtr"/>
                      <div
                        *ngIf="formgroup_ry.get('lxdhCtr').invalid&&formgroup_ry.get('lxdhCtr').dirty">
                          <span *ngIf="formgroup_ry.hasError('myrequire','lxdhCtr')">
                                <tool-tip [o]="formgroup_ry.getError('myrequire','lxdhCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="col-lg-3 control-label">
                      <require-label></require-label>
                      人员类型:
                    </label>
                    <div class="col-lg-8">
                      <select class="form-control" id="rylxselect_form" formControlName="rylxmCtr"></select>
                      <div *ngIf="formgroup_ry.get('rylxmCtr').dirty&&formgroup_ry.get('rylxmCtr').invalid">
                          <span *ngIf="formgroup_ry.hasError('snone','rylxmCtr')">
                             <tool-tip [o]="formgroup_ry.getError('snone','rylxmCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="control-label col-lg-3">
                      <require-label></require-label>
                      身份证件类型:
                    </label>
                    <div class="col-lg-8">
                      <select class="form-control" id="sfzjlxselect_form" formControlName="sfzjlxmCtr"></select>
                      <div *ngIf="formgroup_ry.get('sfzjlxmCtr').dirty&&formgroup_ry.get('sfzjlxmCtr').invalid">
                          <span *ngIf="formgroup_ry.hasError('snone','sfzjlxmCtr')">
                             <tool-tip [o]="formgroup_ry.getError('snone','sfzjlxmCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12">
                  <div class="form-group">
                    <label class="control-label col-lg-3">
                      <require-label></require-label>
                      身份证件号码:
                    </label>
                    <div class="col-lg-8">
                      <input type="text" class="form-control" formControlName="sfzjhmCtr"/>
                      <div *ngIf="formgroup_ry.get('sfzjhmCtr').dirty&&formgroup_ry.get('sfzjhmCtr').invalid">
                          <span *ngIf="formgroup_ry.hasError('numMatchlx','sfzjhmCtr')">
                             <tool-tip [o]="formgroup_ry.getError('numMatchlx','sfzjhmCtr').msg"></tool-tip>
                          </span>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="col-lg-12" id="zpRoom">
                  <div class="form-group">
                    <label class="control-label col-lg-3">
                      <require-label></require-label>
                      照片
                    </label>
                    <div class="col-lg-8">
                      <form-file-input [o]="zpobj_ry" (outMethod)="methodHander($event)"></form-file-input>
                      <div *ngIf="noReactiveFormField.zpwarnflag">
                        <tool-tip [o]="noReactiveFormField.zpwarntext"></tool-tip>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
            <button type="button" class="btn btn-primary" (click)="addsure_ry()">确 定</button>
          </div>
        </div>
      </div>
    </div>
    </div>
  `
})
export class RyglComponent implements OnInit, OnDestroy {
  pagetitleobj: any;
  userinfo: any;
  s_obj: any = {
    xm: "",
    sfzjhm: "",
    rylxm: "",
    sfglrw: ""
  }
  table_ry: any;
  caozuo_rybh: string;
  rygl_btns: any[] = ["ry_add", "ry_refresh"];
  rygl_c_btns: any[] = ["xq_ry", "edite_ry", "remove_ry"];
  hascbtns: any[] = [];
  actionobj1: any[] = [];
  xqobj_ry: any;
  formgroup_ry: FormGroup;
  modalflag: string = "";
  modaltitle: string = "";
  noReactiveFormField: any = {
    sexwarnflag: "",
    sexwarntext: "性别不能为空",
    zpid: "",
    zpwarnflag: false,
    zpwarntext: '照片不能为空'
  }
  zpobj_ry: any;
  selectDefaultField: any = {
    sfzjlxm: "",
    rylxm: ""
  };
  edite_fixedField: any = {
    zpid: ""
  }

  /**
   * 初始化按钮
   */
  initactions(): void {
    // this.commservice.getroleBtns(this.rygl_btns, this.rygl_c_btns, this.userinfo.nowroleid, "tablery", (hasportbtns, hastablebtns) => {
    //   this.actionobj1 = hasportbtns;
    //   this.hascbtns = hastablebtns;
    // });
    this.commservice.getroleBtns_not_permissions(this.rygl_btns, this.rygl_c_btns, "tablery", (hasportbtns, hastablebtns) => {
      this.actionobj1 = hasportbtns;
      this.hascbtns = hastablebtns;
    });
  }

  /**
   * 按钮的处理回调
   * @param e
   */
  actionHander(e: any): void {
    const fromv = e.pfrom;
    const actiontype = e.type;
    if (fromv === "tablery") {
      if (actiontype === "refresh") {
        // 刷新
        this.table_ry = Object.assign({}, this.table_ry);
      } else if (actiontype === "add") {
        // 添加
        this.add_ry();
      }
    }
  }

  /**
   * 添加人员
   */
  add_ry(): void {
    this.modalflag = "add";
    this.modaltitle = "添加押运人员";
    this.formgroup_ry.reset({
      rylxmCtr: this.selectDefaultField.rylxm,
      sfzjlxmCtr: this.selectDefaultField.sfzjlxm
    });
    $("#rylxselect_form").selectpicker("render");
    $("#sfzjlxselect_form").selectpicker("render");
    // 性别
    $(".mt-radio-inline input[name='sex']").eq(0).prop("checked", true);
    // 照片
    this.noReactiveFormField["zpid"] = ""; //
    $("#zpRoom .selectFile").find("input").val(""); // 显示的名字
    this.zpobj_ry["zjlx"] = "add";
    this.zpobj_ry = Object.assign({}, this.zpobj_ry);
    $("#add_ryModal").modal({
      keyboard: true,
      backdrop: "static"
    });
  }

  inittable_ry(): void {
    const that = this;
    this.table_ry = {
      tableid: "table_ry",
      url: "sjgz/jcsj/yyrylb",
      reqobj: this.s_obj,
      sidePagination: "server",
      pageSize: 10,
      pageList: [10, 20, 30],
      total: "totalRows",
      rows: "yyryList",
      columns: [{
        checkbox: true,
        visible: false
      }, {
        title: "序号",
        field: "ordernum",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "姓名",
        field: "xm",
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "性别",
        field: "xb",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        }
      }, {
        title: "身份证件类型",
        field: "sfzjlx",
        cellStyle: function () {
          return {
            classes: 'td4'
          }
        }
      }, {
        title: "身份证件号码",
        field: "sfzjhm",
        cellStyle: function () {
          return {
            classes: 'td1'
          }
        }
      }, {
        title: "人员类型",
        field: "rylx",
        cellStyle: function () {
          return {
            classes: 'td2'
          }
        }
      }, {
        title: "联系电话",
        field: "lxdh",
        cellStyle: function () {
          return {
            classes: 'td3'
          }
        }
      }, {
        title: "创建机构名称",
        field: "cjjgmc",
        cellStyle: function () {
          return {
            classes: 'td4'
          }
        }
      }, {
        title: "操作",
        field: "yyrybh",
        events: this.myevents,
        formatter: function (value, row, index) {
          let str: string = "";
          const islock = row.kdsfkbj;
          if (that.hascbtns.indexOf("edite_ry") != -1) {
            str += "<button type='button' class='btn btn-xs btn-primary edite_ry'><i class='fa fa-pencil'></i> 编辑</button>";
          }

          if (that.hascbtns.indexOf("remove_ry") != -1) {
            str += "<button type='button' class='btn btn-xs btn-warning remove_ry'><i class='fa fa-trash'></i> 删除</button>";
          }

          if (that.hascbtns.indexOf("xq_ry") != -1) {
            str += "<button type='button' class='btn btn-xs btn-info xq_ry'><i class='fa fa-search'></i> 详情</button>";
          }
          return str;
        }
      }]
    };
      // this.table_ry.pageSize = 50;
      // this.table_ry.pageList = [50];
      // this.table_ry.hiddenPageinfoLink = true;
      // this.table_ry.paginationLoop = true;
      // this.table_ry.paginationPreText = "<i class='fa fa-arrow-left'></i>上一页";
      // this.table_ry.paginationNextText = "下一页<i class='fa fa-arrow-right'></i>";
      // this.table_ry.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 50;
      this.table_ry.height = this.commservice.getViewPort().height - this.commservice.topH - this.commservice.topmenuH - 240 - 50;
  }

  @HostListener("window:myevents", ["$event"])
  myevents = {
    "click .xq_ry": function (e, value, row, index) {
      this.caozuo_rybh = value;
      this.xq_ry();
    }.bind(this),
    "click .remove_ry": function (e, value, row, index) {
      this.caozuo_rybh = value;
      if (!this.caozuo_rybh) {
        return
      }
      this.commservice.myswal("warning", "确定删除？", "", "cz", () => {
        this.removeDone_ry();
      });
    }.bind(this),
    "click .edite_ry": function (e, value, row, index) {
      this.caozuo_rybh = value;
      this.edite_ry();
    }.bind(this),
  }

  /**
   * 人员详情
   */
  xq_ry(): void {
    const url = "sjgz/jcsj/yyryxq";
    this.itservice.kwPtPost(url, {
      yyrybh: this.caozuo_rybh
    }).subscribe(resp => {
      this.commservice.handResponse("get", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            this.xqobj_ry = {
              from: "ryglxin",
              keyValue: resp
            };
            $("#xq_ryModal").modal({
              keyboard: true,
              backdrop: "static"
            });
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.xq_ry();
        }
      })
    })
  }

  /**
   * 单条删除
   */
  removeDone_ry(): void {
    const url = "sjgz/jcsj/yyrysc";
    this.itservice.kwPtPost(url, {
      yyrybhs: [this.caozuo_rybh]
    }).subscribe(resp => {
      this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            this.commservice.myswal("success", resp, "", "ts", null);
            this.table_ry = Object.assign({}, this.table_ry);
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.removeDone_ry();
        }
      });
    })
  }


  /**
   * 添加/编辑表单
   */
  createformgroup_ry(): void {
    this.formgroup_ry = this.fb.group({
      xmCtr: ["", [this.myValidator.myrequired("姓名")]],
      lxdhCtr: ['', [this.myValidator.islxdh(true)]],
      rylxmCtr: ["", [this.myValidator.selecthas()]],
      sfzjlxmCtr: ["", [this.myValidator.selecthas()]],
    });
    const sfzjlxctr = this.formgroup_ry.get('sfzjlxmCtr') as FormControl;
    const sfzjhmCtrv = new FormControl("", [this.myValidator.numMatchlx(sfzjlxctr)]) as FormControl;
    this.formgroup_ry.addControl("sfzjhmCtr", sfzjhmCtrv);
    // 照片
    this.zpobj_ry = {
      autoup: true,
      allowedFileType: ["image"],
      zjlx: "add",
    };
    $("#zpRoom").find(".selectFile").click(function () {
      $("#zpRoom").find(".ngselectFileInput").click();
    });
    // 人员类型，身份证件类型， 见 搜索表单的创建
  }


  /**
   * 照片选择上传完毕的回调
   * @param e
   */
  methodHander(e: any): void {
    const result_code = e.flag;
    if (result_code === "success") {
      const zpid = e.fileId;
      const zppath = e.filepath;
      this.noReactiveFormField["zpid"] = zpid;
    }
  }

  /**
   * 编辑人员信息
   */
  edite_ry(): void {
    if (!this.caozuo_rybh) {
      return
    }
    this.modalflag = "edite";
    this.modaltitle = "编辑押运人员";
    const url = "sjgz/jcsj/yyryxq";
    this.itservice.kwPtPost(url, {
      yyrybh: this.caozuo_rybh
    }).subscribe(resp => {
      this.commservice.handResponse("get", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            const xmv = resp.xm;
            const xbmv = resp.xbm;
            const lxdhv = resp.lxdh;
            const rylxmv = resp.rylxm;
            const sfzjlxmv = resp.sfzjlxm;
            const sfzjhmv = resp.sfzjhm;
            const zpv = resp.zp;
            const zpurlv = resp.zpurl;

            this.formgroup_ry.patchValue({
              xmCtr: xmv,
              lxdhCtr: lxdhv,
              rylxmCtr: rylxmv,
              sfzjlxmCtr: sfzjlxmv,
              sfzjhmCtr: sfzjhmv
            });
            $("#rylxselect_form").selectpicker("render");
            $("#sfzjlxselect_form").selectpicker("render");
            // 性别
            if (xbmv == "1") {
              $(".mt-radio-inline input[name='sex']").eq(0).prop("checked", true);
            } else {
              $(".mt-radio-inline input[name='sex']").eq(1).prop("checked", true);
            }
            // 照片
            this.noReactiveFormField.zpid = "";
            $("#zpRoom .selectFile").find("input").val(""); // 显示的名字
            this.edite_fixedField["zpid"] = zpv;
            this.zpobj_ry["zjlx"] = "edite";
            this.zpobj_ry["filepath"] = zpurlv;
            this.zpobj_ry = Object.assign({}, this.zpobj_ry);
            $("#add_ryModal").modal({
              keyboard: true,
              backdrop: "static"
            });
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.xq_ry();
        }
      })
    })
  }

  /**
   * 验证+ 保存
   */
  addsure_ry(): void {
    if (this.formgroup_ry.invalid) {
      const ctrols = this.formgroup_ry.controls;
      for (let path in ctrols) {
        ctrols[path].markAsDirty();
        ctrols[path].updateValueAndValidity();
      }
      return;
    }
    const actionflag = this.modalflag;
    let zpv: string = "";
    let zpscv: string = "";
    if (actionflag === "add") {
      zpv = this.noReactiveFormField["zpid"];
    } else if (actionflag === "edite") {
      if (!this.noReactiveFormField["zpid"]) {
        zpv = this.edite_fixedField["zpid"];
      } else {
        zpv = this.noReactiveFormField["zpid"];
        zpscv = this.edite_fixedField["zpid"];
      }
    }
    if (!zpv) {
      this.noReactiveFormField.zpwarnflag = true;
      return
    }
    this.noReactiveFormField.zpwarnflag = false;
    const formgroupv = this.formgroup_ry.getRawValue();
    const xmv = this.commservice.removeSpace(true, formgroupv.xmCtr);
    let xbmv: string = "1";  // 性别码
    let xbv: string = "男";
    if (!$(".mt-radio-inline input[name='sex']").eq(0).prop("checked")) {
      xbmv = "2";
      xbv = "女";
    }
    const sfzjlxmv = this.commservice.removeSpace(true, formgroupv.sfzjlxmCtr);
    const sfzjlxv = this.commservice.removeSpace(true, $("#sfzjlxselect_form option:selected").text());
    const sfzjhmv = this.commservice.removeSpace(true, formgroupv.sfzjhmCtr);
    const lxdhv = this.commservice.removeSpace(true, formgroupv.lxdhCtr);
    const rylxmv = this.commservice.removeSpace(true, formgroupv.rylxmCtr);
    const rylxv = this.commservice.removeSpace(true, $("#rylxselect_form option:selected").text());
    this.commservice.blockUI({
      boxed: true,
      message: "保存中...",
      zIndex: 10051,
      overlayColor: "#67809F"
    });
    if (actionflag == "add") {
      const url = "sjgz/jcsj/yyryxz";
      this.itservice.kwPtPost(url, {
        xm: xmv,
        xbm: xbmv,
        xb: xbv,
        sfzjlxm: sfzjlxmv,
        sfzjlx: sfzjlxv,
        sfzjhm: sfzjhmv,
        zp: zpv,
        lxdh: lxdhv,
        rylxm: rylxmv,
        rylx: rylxv
      }).subscribe(resp => {
        this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
          if (arg1) {
            if (arg2) {
              this.commservice.myswal("success", resp, "", "ts", null);
              this.table_ry = Object.assign({}, this.table_ry);
              $("#add_ryModal").modal("hide");
            } else {
              this.commservice.myswal("warning", resp, "", "ts", null);
            }
          } else {
            this.addsure_ry();
          }
        });
      })
    } else if (actionflag == "edite") {
      const url = "sjgz/jcsj/yyryxg";
      this.itservice.kwPtPost(url, {
        yyrybh: this.caozuo_rybh,
        xm: xmv,
        xbm: xbmv,
        xb: xbv,
        sfzjlxm: sfzjlxmv,
        sfzjlx: sfzjlxv,
        sfzjhm: sfzjhmv,
        zp: zpv,
        zpsc: zpscv,
        lxdh: lxdhv,
        rylxm: rylxmv,
        rylx: rylxv
      }).subscribe(resp => {
        this.commservice.handResponse("put", url, resp, (arg1, resp, arg2) => {
          if (arg1) {
            if (arg2) {
              this.commservice.myswal("success", resp, "", "ts", null);
              this.table_ry = Object.assign({}, this.table_ry);
              $("#add_ryModal").modal("hide");
            } else {
              this.commservice.myswal("warning", resp, "", "ts", null);
            }
          } else {
            this.addsure_ry();
          }
        });
      })
    }
  }

  /**
   * 处理搜索表单
   */
  createsearchForm(): void {
    // 人员类型
    const mbywmcstr = "jy_rylxdmb;gj_sfzjdmb";
    this.commservice.getmbzd(mbywmcstr, (resp, flag) => {
      if (flag) {
        const rylxList = resp[0];
        const srzjlxList = resp[1];
        $("#rylxSelect").empty();
        $("#rylxselect_form").empty();
        let str: string = "<option value=''>--请选择--</option>";
        rylxList.forEach((item) => {
          str += "<option value='" + item.DM + "'> " + item.MC + "</option>";
        });
        $("#rylxSelect").append(str);
        $("#rylxSelect").selectpicker({
          size: 5
        });
        this.s_obj.rylxm = "";  // 全部查询
        $("#rylxselect_form").append(str);
        $("#rylxselect_form").selectpicker({
          size: 5
        });
        this.selectDefaultField.rylxm = "";

        // 身份证件类型
        $("#sfzjlxselect_form").empty();
        let str2: string = "<option value=''>--请选择--</option>";
        srzjlxList.forEach((item) => {
          str2 += "<option value='" + item.DM + "'>" + item.MC + "</option>";
        });
        $("#sfzjlxselect_form").append(str2);
        $("#sfzjlxselect_form").selectpicker({
          size: 5
        });
        this.selectDefaultField.sfzjlxm = "";
      }
    });
    // 是否关联押运任务
    const datalist = [{
      code: "0",
      name: "已关联"
    }, {
      code: "1",
      name: '未关联'
    }];
    $("#sfglrwSelect").empty();
    let str2: string = "<option value=''>--请选择--</option>";
    datalist.forEach((item) => {
      str2 += "<option value='" + item.code + "'>" + item.name + "</option>";
    });
    $("#sfglrwSelect").append(str2);
    $("#sfglrwSelect").selectpicker({
      size: 5
    });
    this.s_obj.sfglrw = ""; // 全部
  }

  /**
   * 获取用户信息
   */
  getuserinfo(): void {
    this.commservice.getUserinfo((info) => {
      this.userinfo = info;
      this.initactions(); //用户按钮权限
    });
  }

  constructor(private commservice: CommService,
    private itservice: MyhttpService,
    private fb: FormBuilder,
    private myValidator: MyValidator) {

  }

  ngOnInit() {
    this.pagetitleobj = sjgzxinModuledatas.rygl;
    this.getuserinfo();
    this.createsearchForm();
    this.inittable_ry();
    this.createformgroup_ry();

  }

  ngOnDestroy() {

  }

}
